package com.bytedance.frameworks.a.c;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import com.bytedance.frameworks.a.b.MutableContext;
import icepick.Icepick;

public abstract class BaseFragment extends Fragment {
    private MutableContext mMutableContext;

    public BaseFragment() {

    }

    public final boolean isFinishing() {
        return this.getActivity() == null || (this.getActivity().isFinishing());
    }

    public void onAttach(Context context) {
        super.onAttach(context);
        if(this.mMutableContext == null || this.mMutableContext.getBaseContext() != context) {
            this.mMutableContext = new MutableContext(context);
        }
    }

    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Icepick.restoreInstanceState(this, savedInstanceState);
    }

    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Icepick.saveInstanceState(this, outState);
    }
}

